package cn.bytets.rpc.api.message;

import cn.bytets.rpc.common.utils.StringUtils;

public class ResponseBuild {

    public static Response build(long id,String version,Object result){
        return new Response(id,version,result);
    }
    /**
     * 封装异常返回Response
     * @param request
     * @param t
     * @return
     */
    public static Response buildErrorResponse(Request request, Throwable t) {
        Response response = new Response(request.getId(), request.getVersion());
        response.setStatus(Response.SERVICE_ERROR);
        response.setErrorMessage(StringUtils.toString(t));
        return response;
    }
}
